package com.xframe.domain;

import com.xframe.xdal.core.model.IModel;

public class CommandBodyContainer {

    /**
     * 线程对象
     */
    private static final ThreadLocal<CommandModel> container = new ThreadLocal<CommandModel>();

    private static final ThreadLocal<IModel> modelThreadLocal = new ThreadLocal<IModel>();
    /**
     * 添加一个命令请求体
     *
     * @param commandModel 请求体
     */
    public static void addCommandModel(CommandModel commandModel){
        container.set(commandModel);
    }

    /**
     * 添加一个命令请求体
     *
     * @param model 请求体
     */
    public static void addModel(IModel model){
        modelThreadLocal.set(model);
    }
    /**
     * 获取一个命令请求体到线程对象中
     * @return CommandModel
     */
    public static CommandModel getCommandModel(){
        return container.get();
    }

    public static IModel getModel(){
        return modelThreadLocal.get();
    }

    /**
     * 移除用户凭证
     */
    public static void remove(){
        container.remove();
        modelThreadLocal.remove();
    }
}
